Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1K
Views
How to solve error : [vuex] unknown action type: (method)

I am trying to display data with vuex from api using store (vuex)

so this is my store.js file :

import { createStore } from 'vuex'
import countries from './module/countries'

const store = createStore({
  modules: {
    countries
  }
});

export default store;

countries.js file

import axios from "axios";

const state = {
  countries:  []
};
const getters = {
  getCountries: () => {
    return state.countries;
  }
};
const mutations = {
  setCountries(state, countries) {
    state.countries = countries;
  }
};
const actions = {
  getCountries ({ commit }) {
    axios.get("https://localhost:44391/api/Pho/GetCountries").then(response => {
       commit('setCountries', response.data);
    })
  }
};
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
};

and this is my component

 methods: {
   getCountries() {
      this.$store.dispatch('getCountries');
   },

When i run the application i got this error [vuex] unknown action type: getCountries

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using namespaced modules, so try like:

this.$store.dispatch('countries/getCountries');

and call your geter like:

computed: {
  getData() {
    return this.$store.getters['countries/getCountries']
  }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!